﻿@{
    ViewData["Title"] = "添加菜单";
    Layout = "_Edit";
}
<article class="page-container">
    <form action="" method="post" class="form form-horizontal" id="form-add">
        <input type="hidden" class="input-text" value="@Model.Id" id="id" name="id">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red" >*</span>菜单名：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.FullName" placeholder="" id="fullName" name="fullName">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">菜单URL：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.Url" placeholder="" id="url" name="url">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">上级菜单：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
                    <select class="select" size="1" name="pId">
                        @if (Model.Pid != 0)
                        {
                            <option value="0" selected>无</option>
                        }
                        else
                        {
                            <option value="0">无</option>
                        }
                        @foreach (var item in Model.List)
                        {
                            if (Model.Pid == item.ID)
                            {
                                <option value="@item.ID" selected>@item.FullName</option>
                            }
                            else
                            {
                                <option value="@item.ID">@item.FullName</option>
                            }
                        }
                    </select>
                </span>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red" style="margin-left:20px">*</span>状态：</label>
                <div class="formControls col-xs-8 col-sm-9 skin-minimal">
                    <div class="radio-box">
                        @if (Model.Status == 1 || Model.Status == 0)
                        {
                            <input name="status" type="radio" id="Status-1" value="1" checked>
                        }
                        else
                        {
                            <input name="status" type="radio" id="Status-1" value="1">
                        }
                        <label for="sex-1">正常</label>
                    </div>
                    <div class="radio-box">
                        @if (Model.Status == 2)
                        {
                            <input type="radio" id="Status-2" name="status" value="2" checked>
                        }
                        else
                        {
                            <input type="radio" id="Status-2" name="status" value="2">
                        }
                        <label for="sex-2">禁用</label>
                    </div>
                </div>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">备注：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <textarea name="des" cols="" rows="" class="textarea" placeholder="说点什么..."></textarea>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="button" onclick="operateFunction()" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>

@section javascript{

<script>
    $('.skin-minimal input').iCheck({
         checkboxClass: 'icheckbox-blue',
         radioClass: 'iradio-blue',
         increaseArea: '20%'
     });
     function operateFunction(){
         var fullname=$("#fullName").val();
         if(fullname==null||fullname=="")
         {
            popupAlert('菜单名不能为空',2,function(data){layer.close(data);});
           return;
         }
        SubmitFormForAjax("/admin/operatefunction", $("#form-add").serialize(), function (data) {
            if (data.result) {
                    popupAlert('提交成功',1,function(){closePageLayer(true);});
            }else{
                popupAlert(data.message,2,function(data){layer.close(data);});
            }
        },true);
     }
</script>
}